farebny riadok v DBGrid

Otázka od: X-Tech

14. 8. 2004 7:17

zdravim,
zacinam a potrebujem usmernit.
existuje nieco aby som spravil v DBGride cely riadok farebny?
dakujem,
 
Marek Janosik


Odpovedá: Martin Burle

14. 8. 2004 16:00

> existuje nieco aby som spravil v DBGride cely riadok farebny?

Zkus neco takoveho:


procedure TFrmPickItem.GridItemsDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);

 function IsValid: Boolean;
 begin
  with GridItems.DataSource.dataset do begin
      Result := FieldByName('VOLNYCH').AsFloat>0;
  end;
 end;

begin
 if Isvalid then begin
    GridItems.Canvas.Font.Color := clBlack;
    GridItems.Canvas.Brush.Color := clWhite;
 end else begin
    GridItems.Canvas.Font.Color := clGray;
    GridItems.Canvas.Brush.Color := clRed;
 end;
 GridItems.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

HTH,

MB


Odpovedá: Jirka Virt

14. 8. 2004 19:22

Nic proti, ale tohle se tu a na jinych podobnych konferencich probiralo
snad tisickrat.Staci hledat.

Jirka Virt


Odpovedá: Marek

16. 8. 2004 5:19

 
ahoj,

na DrawColumnCell zkus

na bunku
  if Column.FieldName = 'WEIGHT' then
    if DBGrid1.fields[2].Text='xxx' then begin
      DBGrid1.Canvas.Brush.Color := clRed;
      DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
       end;

na radak
 if DBGrid1.fields[2].Value=15 then begin
      DBGrid1.Canvas.Brush.Color := clAqua;
      DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);

Marek

zdravim,
zacinam a potrebujem usmernit.
existuje nieco aby som spravil v DBGride cely riadok farebny?
dakujem,
 
Marek Janosik